home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / ae / code / ax3.00 / save_account.c < prev    next >
Encoding:
C/C++ Source or Header  |  1980-01-03  |  1.5 KB  |  66 lines

  1. #include "bbs.h"
  2. /* if flg > 0 then force save account */
  3. int Save_Account(struct User *hoozer, struct UserKeys *hoozer2, int uslot, int flg)
  4. {
  5.  long slot,stat;
  6.  BPTR fh;
  7.  if(OnlineEdit && Whence_The_Logon>=REMOTE_LOGON)
  8. {
  9.  sprintf(GSTR3,"\tSaved account %4d %s\n",hoozer->Slot_Number,hoozer->Name);
  10.  CallersLog(GSTR3);
  11. }
  12.  if(flg) {                /* Force Save User Account */
  13.      uslot-=1;
  14.      slot = uslot;
  15.  
  16.  } else {
  17.      if(hoozer->Slot_Number==0)  return(FAILURE);
  18.      slot=hoozer->Slot_Number-1;
  19.  }
  20.  
  21.  //strcpy(GSTR1,Cmds->BBSLoc);
  22.  //strcat(GSTR1,"User.Data");
  23. strcpy(GSTR1,UserDataLoc);
  24.  fh=Open(GSTR1,MODE_OLDFILE);
  25.  if(fh==NULL)  return(FAILURE);
  26.  
  27.  stat=MySeek(fh,(((long)sizeof(struct User))*(long)slot),OFFSET_BEGINNING);
  28.  if(stat!=(((long)sizeof(struct User))*(long)slot)) {
  29.      Close(fh);
  30.         return(FAILURE);
  31.     }
  32.  
  33.  stat=Write(fh,(char *)hoozer,sizeof(struct User));
  34.  if(stat!=sizeof(struct User)) {
  35.      Close(fh);
  36.         return(FAILURE);
  37.     }
  38.  
  39.  Close(fh);
  40.  
  41.  //strcpy(GSTR1,Cmds->BBSLoc);
  42.  //strcat(GSTR1,"User.keys");
  43. strcpy(GSTR1,UserKeyLoc);
  44.  fh=Open(GSTR1,MODE_OLDFILE);
  45.  if(fh==NULL)  return(FAILURE);
  46.  
  47.  stat=MySeek(fh,(((long)sizeof(struct UserKeys))*(long)slot),OFFSET_BEGINNING);
  48.  if(stat!=(((long)sizeof(struct UserKeys))*(long)slot)) {
  49.      Close(fh);
  50.         return(FAILURE);
  51.     }
  52.  
  53.  if(hoozer->New_User)    hoozer2->New_User=1;
  54.  else                    hoozer2->New_User=0;
  55.  
  56.  stat=Write(fh,(char *)hoozer2,sizeof(struct UserKeys));
  57.  if(stat!=sizeof(struct UserKeys)) {
  58.      Close(fh);
  59.         return(FAILURE);
  60.     }
  61.  
  62.  Close(fh);
  63.  
  64.  return(SUCCESS);
  65. }
  66.